$ ->
    $view = $('.view-index')
    $btnClose = $('.btn-close')

    $btnClose.on 'click', (e)->
        W.preventDefault e
        $this = $ e.currentTarget
        $topic = $this.closest('.topic')
        title = $topic.attr('data-title')
        id = $topic.attr('data-id')
        id = id.replace('"', '').replace('"', '')
        return unless id
        swal {
            title: "确定要删除 '#{title}' ?",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "删除!",
            closeOnConfirm: false
        },
            ()->
                q = W.api.remove "topic/#{id}"
                q.then ->
                    swal({title: "删除成功!", type: "success"}, ()-> location.reload())
                q.catch W.alertAjaxError e
